package 接口.基础;
//多个接口
abstract class Animal{
    String name;
    int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    abstract void eat();
}
interface IRUNNING {
    void run();
}
interface ISWIMMING{
    void swim();
}
class Dog extends Animal implements IRUNNING,ISWIMMING{

    Dog(String name ,int age){
        super(name,age);
    }
    @Override
    void eat() {
        System.out.println(name+"吃狗粮");
    }

    @Override
    public void run() {
        System.out.println(name+"用狗腿跑");
    }

    @Override
    public void swim() {
        System.out.println(name+"用狗腿游");
    }
}
public class interface_2 {
    static void fun1(Animal animal){
        animal.eat();
    }
    static void fun2(IRUNNING irunning){//粗略理解为接口当父类用
        irunning.run();
    }
    static void fun3(ISWIMMING iswimming){
        iswimming.swim();
    }
    public static void main(String[] args) {
        Dog dog = new Dog("小黄",2);
        fun1(dog);//向上转型
        fun2(dog);//向上转型
        fun3(dog);//向上转型
    }
}
